// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueI18n from 'vue-i18n'
import {zh, en, chtw, ja} from '@/common/lang'
import ViewUI from 'view-design'
import vueSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
import 'view-design/dist/styles/iview.css' // 通过插件的形式挂载
import utils from '@/common/api/tool.js'
// import VueSocketIO from 'vue-socket.io'
// Vue.use(new VueSocketIO({
//   debug: true,
//   connection: 'http://metinseylan.com:1992'
//   // connection: 'wss://chat.hll666.xyz/websocket/5eb7e1aa-ed7a-42a7-bc0b-f5901d99cc76/zh-CN'
// }))
Vue.use(vueSwiper)
Vue.use(ViewUI)
Vue.use(VueI18n)
var language = utils.getCookie('language') ? utils.getCookie('language') : localStorage.getItem('locale') || 'zh-TW'
const i18n = new VueI18n({
  locale: language, // 语言标识
  // this.$i18n.locale // 通过切换locale的值来实现语言切换
  messages: {
    'zh-CN': zh, // 中文语言包
    'en-US': en, // 英文语言包
    'zh-TW': chtw,
    'ja': ja
  }
})
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  i18n,
  components: { App },
  template: '<App/>'
})
// function getToken (name) {
//   var arr = []
//   var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
//   if ((arr = document.cookie.match(reg))) {
//     if (
//       unescape(arr[2]).substring(0, 1) === '"' ||
//       unescape(arr[2]).substring(0, 1) === '\''
//     ) {
//       return unescape(arr[2]).substring(1, unescape(arr[2]).length - 1)
//     } else {
//       return unescape(arr[2])
//     }
//   } else return null
// }
